package com.zhkj.txg.module.mine.ui

import android.app.Activity
import android.content.Intent
import android.view.View
import com.zhkj.lib.base.BaseActivity
import com.zhkj.txg.R
import com.zhkj.txg.module.mine.entity.ReferrerChildEntity
import com.zhkj.txg.utils.ImageUtils
import kotlinx.android.synthetic.main.activity_referrer.*

class ReferrerActivity : BaseActivity() {

    companion object {

        private val EXTRA_INFO = "info"

        fun start(activity: Activity, info: ReferrerChildEntity) {
            val intent = Intent(activity, ReferrerActivity::class.java).putExtra(EXTRA_INFO, info)
                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
            activity.startActivity(intent)
        }
    }

    override val layoutResId: Int = R.layout.activity_referrer
    override fun statusTitleBar(): View? = titleInvite
    override fun initUI() {
        (intent.getSerializableExtra(EXTRA_INFO) as? ReferrerChildEntity)?.let {
            ImageUtils.loadCircleImage(this, ivAvatar, it.avatar ?: "")
            tvNickname.text = it.nickname
            tvMobile.text = it.mobile
            tvInviteCode.text = buildString {
                append("邀请码:")
                append(it.invite_code)
            }
        }
    }
}